package com.homson.coreservice.servicecommon.enumeration;


import static com.homson.coreservice.servicecommon.enumeration.AccountTypeEnum.*;
import static com.homson.coreservice.servicecommon.enumeration.TransTypeEnum.*;

/**
 * @author: homson_leo
 * @contact: hey_超级巨星（Homson_Leo）- 刘泓岑 1196816884@qq.com
 * @time: 2025/11/15 4:49 PM
 **/
public enum TransCategoryEnum {
    BUY_STOCK(4001, STOCK, INCOME, "买入股票"),
    SELL_STOCK(4002, STOCK, DEBIT, "卖出股票"),
    BUY_FUND(4003, FUND, INCOME, "买入基金"),
    SELL_FUND(4004, FUND, DEBIT, "卖出基金"),
    TRANSFER_IN(4005, DOM_BANK, TRANSFER, "境内转账"),
    TRANSFER_OUT(4006, DOM_BANK, TRANSFER, "境内转账"),
    INCOME_IN(4010, DOM_BANK, INCOME, "境内入账"),
    DEBIT_OUT(4011, DOM_BANK, DEBIT, "境内扣账"),
    FORE_TRANSFER_IN(4007, FOREIGN_BANK, TRANSFER, "离岸转账"),
    FORE_TRANSFER_OUT(4008, FOREIGN_BANK, TRANSFER, "离岸转账"),
    CONSUMPTION(4009, OTHERS, DEBIT, "消费");
    
    private final int code;
    private final AccountTypeEnum accountType;
    private final TransTypeEnum transType;
    private final String description;
    
    TransCategoryEnum(int code, AccountTypeEnum accountType, TransTypeEnum transType, String description) {
        this.code = code;
        this.accountType = accountType;
        this.transType = transType;
        this.description = description;
    }
    
    public static TransCategoryEnum of(AccountTypeEnum accountType, TransTypeEnum transType) {
        if (accountType == null || transType == null) {
            return null;
        }
        
        for (TransCategoryEnum category : TransCategoryEnum.values()) {
            if (category.getAccountType() == accountType && category.getTransType() == transType) {
                return category;
            }
        }
        return null;
    }
    
    public int getCode() {
        return code;
    }
    
    public AccountTypeEnum getAccountType() {
        return accountType;
    }
    
    public TransTypeEnum getTransType() {
        return transType;
    }
    
    public String getDescription() {
        return description;
    }
}
